#include <cstdio>
#include <memory.h>

int d[ 100001 ], s[ 100001 ], n, m;

int find( int root )
{
    int p = root, t;
    if ( s[ root ] == -1 )
        return root;
    while ( s[ p ] != -1 ) p = s[ p ];
    while ( root != p )
    {
        t = s[ root ];
        s[ root ] = p;
        root = t;
    }
    return p;
}

void merge( int root1, int root2 )
{
    root1 = find( root1 );
    root2 = find( root2 );
    if ( root1 != root2 )
        s[ root1 ] = root2;
}

void init( )
{
    int i, u, v;
    memset( d, 0, sizeof( d ) );
    for ( i = 0; i < n; i++ ) s[ i ] = -1;
    for ( i = 0; i < m; i++ )
    {
        scanf("%d%d", &u, &v);
        d[ u ]++; d[ v ]++;
        merge( u, v );
    }
}

void work( )
{
    int i, c1 = 0, c2 = 0, j;
    for ( i = 0; i < n; i++ )
        if ( s[ i ] == -1 )
        {
            c1++;
            for ( j = 0; j < n; j++ )
                if ( find( j ) == i && d[ j ] != 2 )
                    break;
            c2 += j == n;
        }
    printf("%d %d\n", c1, c2);
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        if ( n == 0 && m == 0 ) break;
        init( );
        work( );
    }
    return 0;
}
